<?php
	####################################################
	# library import and object instance.              #
	####################################################
	# 커먼 인클루드
	include_once( '../common.php' );

	####################################################
	# request data($_POST AND $_GET FROM $_REQUEST)    #
	####################################################
	# REQUEST(get and post variables)
	//$req = Request::clean_request($_REQUEST, FALSE);

	# GET(url variables)

	# POST(form variables)

	# Validation(special case validate)

	####################################################
	# implementation                                   #
	####################################################
	$sec->individual_access();
	$sec->run_cookie_check();

	# 파일을 파싱 한다 '@@todo' 를 파싱하여 배열로 만든다.
	$dir			= IoFileAndDir::dirmap($DEFAULT_PATH);
	//Nlog::puts($dir);
	$STRING_preg	= "/((.*?)@@todo(.*?))/i";
	$file_arr		= array();
	$target_dir		= array('applications','classes', 'js', 'css');
	$blist			= array( 'admin.todolist.index.php', 'class.Scaffold.php');

	foreach($target_dir as $tkey=>$tval){
		$dirtval = $dir[$tval];
		//Nlog::puts($dirtval);
		foreach($dirtval as $key=>$val){
			if(is_array($val) == FALSE){
				if($tval != 'root') {
					$file = $tval.DIRECTORY_SEPARATOR.$val;
				} else {
					$file = $val;
				}
			} else {
				$file = $val;
				continue;
			}
			$fh = fopen('../'.$file, "r");
			$i = 0;
			if(!in_array($val, $blist)) {
				while($line=fgets($fh)) {
					$rem = $line;
					preg_match_all($STRING_preg, $line, $matches, PREG_SET_ORDER);
					foreach ($matches as $v) {
						if($v[0] != ''){
							$file_arr[$file][$i] = $rem;
						}
					}
					$i++;
				}
				fclose($fh);
			}
		}
	}
?>
<?php
	# HTML START
	echo $html->custom_header(TITLE);
	echo $tplt->page_construct_javascript();
	echo $html->custom_js("{$JS}common.js");
	echo $html->custom_css("{$CSS}common.css");
	echo $html->custom_body();
?>
	<?php $tplt->app_head($NAVI)?>
	<?php $tplt->tiles_admin_sidebar($NAVI)?>
	<?php $tplt->tiles_admin_contents($pkname, $pname, $pdesc)?>

		<h4>투두 리스트</h4>
		<table class="tbl" width="100%" border="1" cellspacing="0" cellpadding="1" style="border-collapse:collapse;">
			<colgroup>
				<col width="30%" />
				<col width="70%" />
			</colgroup>
			<?php foreach($file_arr as $key=>$valarr): ?>
				<tr>
					<th align="left" class="ti10"><?=$key?></th>
					<td>
						<table class="tbl" width="100%" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;">
							<colgroup>
								<col width="40" />
								<col width="*" />
							</colgroup>
							<tr>
								<th class="ti0 tac">라인</th>
								<th>내용</th>
							</tr>
							<?php foreach($valarr as $k=>$v):?>
							<tr>
								<td>
									<?=$k?>
								</td>
								<td>
									<?=$v?>
								</td>
							</tr>
							<?php endforeach?>
						</table>
					</td>
				</tr>
			<?php endforeach; ?>
		</table>

<?php
	# HTML END
	echo $tplt->tiles_admin_footer();
	echo $tplt->page_destruct_javascript();
	include_once( '../endproc.php' );
	echo $html->html_footer();
?>